﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Com.Web.coffinegurunaru.AppLogic.Page;
using Com.Framework;
using Com.Framework.Data;
using Com.Library.DB.Advertise;

namespace Com.Web.coffinegurunaru.aboutus
{
	public partial class ad_ppl : WebPage
	{
		public int PageNo
		{
			get;
			set;
		}

		public byte PageSize
		{
			get { return 4; }
		}

		public List<AdvertiseEntity> AdvertiseList
		{
			get;
			set;
		}

		public AdvertiseEntity AdvertiseInfo
		{
			get;
			set;
		}

		public int AdvertiseNo
		{
			get;
			set;
		}

		protected void Page_Load(object sender, EventArgs e)
		{
			this.LeftMenuType = 3;
			PageNo = Request.QueryString["PageNo"].Parse(1);
			AdvertiseNo = Request.QueryString["AdvertiseNo"].Parse(0);

			ListData<AdvertiseEntity, OutputEntity> result = AdvertiseModel.GetList(2, PageNo, PageSize);
			if (AdvertiseNo == 0)
			{
				if (result.Record.Count > 0)
				{
					AdvertiseInfo = result.Record[0];
					AdvertiseNo = AdvertiseInfo.AdvertiseNo;
				}
				else
				{
					AdvertiseInfo = new AdvertiseEntity();
				}
			}
			else
			{
				AdvertiseInfo = AdvertiseModel.GetInfo(AdvertiseNo);
			}
			AdvertiseList = result.Record;

			UC_Paging.TotalCount = result.Output.CntTotal;
			UC_Paging.PageName = "PageNo";
			UC_Paging.PageNo = PageNo;
			UC_Paging.PageSize = PageSize;
			UC_Paging.Query = "AdvertiseNo=" + AdvertiseNo.ToString();
		}

		public string GetURL(int AdvertiseNo)
		{
			return "/aboutus/ad_ppl.aspx?PageNo=" + this.PageNo.ToString() + "&AdvertiseNo=" + AdvertiseNo.ToString();
		}
	}
}
